#!/usr/bin/env python
#-*- coding:utf-8 -*-

import os
import sys
import string
import ConfigParser
import connectMongoDB

def update(filename):
    conn = connectMongoDB.connMongoDB_2()
    db = conn.stat
    collection = db['clientUser']
    file_object = open(filename)
    for line in file_object:
        s = ','
        pos = line.find(s)
        guid = line[0:pos]
        lasttime = line[pos+1:]
        print guid
        print lasttime
        collection.update({'guid':guid}, {'$set':{'lasttime':int(lasttime)}}})
    file_object.close()

def main():
    if len(sys.argv)!=2:
        exit(1)
    update(sys.argv[1])

if __name__ == '__main__':
    main()

